<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<ui:remove>
	Parámetros requeridos por el formulario:
	subcaracteristicaObject->Objeto de tipo Subcaracteristicavalor que se usa dentro del formulario
	prepId->Prepend Id para el formulario, debido a que se requiere unicidad en los ids
	renderRequired->Booleano que indica si se muestran o no las validaciones de requerido
			y además valida los respectivos campos como requeridos
	beanSubcaracteristica->Bean que contiene las funciones requeridas para el formulario
						(onCaracteristicaChange, onSubcaracteristicaChange)
	disableAllFields->Propiedad que indica si se deben deshabilitar todos los campos de la forma
	fileUploadContainerId->Identificador del componente de carga de archivos si es requerido actualizar
			tras los cambios en las selecciones de característica y subcaracterística
	modoConsulta->Booleano que identifica si los campos están en modo lectura
	</ui:remove>

	<h:panelGrid columns="2">
		<h:outputLabel
			value="${msg['bienes.caracteristicasFields.caracteristica']}" />
		<h:outputLabel value="*" rendered="#{renderRequired}" />
	</h:panelGrid>
	<h:panelGrid>
		<h:selectOneMenu id="#{prepId}caracteristicaCB"
			required="#{renderRequired}"
			validatorMessage="${msg['general.requerido']}"
			requiredMessage="${msg['general.requerido']}"
			disabled="#{disableAllFields}"
			value="#{subcaracteristicaObject.tpSubcaracteristicaBien.tpCaracteristicaBien.tpCaracteristicaBien}">
			<f:selectItems
				value="#{applicationBean.getTpCaracteristicaBiensByIdTipoBien(subcaracteristicaObject.bien.tpBienBean.tpBien)}" />
			<f:ajax execute="@this"
				listener="#{beanSubcaracteristica.onCaracteristicaChange}"
				render="#{prepId}tipoCaracteristicaIT #{prepId}labelSubcaracteristicaContainer #{prepId}subcaracteristicaCB #{prepId}camposDinamicos #{prepId}valorLabelContainer #{fileUploadContainerId}" />
		</h:selectOneMenu>
		<h:message for="#{prepId}caracteristicaCB"
			errorClass="validationErrorMessage" showSummary="false" />
	</h:panelGrid>

	<h:outputLabel
		value="${msg['bienes.caracteristicasFields.tipoCaracteristica']}" />
	<h:inputText id="#{prepId}tipoCaracteristicaIT"
		value="#{subcaracteristicaObject.tpSubcaracteristicaBien.tpCaracteristicaBien.tipoCaracteristica}"
		disabled="true" />

	<h:panelGrid columns="2" id="#{prepId}labelSubcaracteristicaContainer">
		<h:outputLabel
			value="${msg['bienes.caracteristicasFields.subCaracteristica']}" />
		<h:outputLabel value="*"
			rendered="#{renderRequired or (modoConsulta and subcaracteristicaObject.tpSubcaracteristicaBien.tpCaracteristicaBien.tpCaracteristicaBien ne null)}" />
	</h:panelGrid>
	<h:panelGrid>
		<h:selectOneMenu id="#{prepId}subcaracteristicaCB"
			required="#{renderRequired or (modoConsulta and subcaracteristicaObject.tpSubcaracteristicaBien.tpCaracteristicaBien.tpCaracteristicaBien ne null)}"
			validatorMessage="${msg['general.requerido']}"
			requiredMessage="${msg['general.requerido']}"
			disabled="#{disableAllFields}"
			value="#{subcaracteristicaObject.tpSubcaracteristicaBien.tpSubcaracteristica}">
			<f:selectItems
				value="#{applicationBean.getTpSubcaracteristiaBienByIdTpCaracteristica(subcaracteristicaObject.tpSubcaracteristicaBien.tpCaracteristicaBien.tpCaracteristicaBien)}" />
			<f:ajax execute="@this"
				listener="#{beanSubcaracteristica.onSubcaracteristicaChange}"
				render="#{prepId}camposDinamicos #{prepId}valorLabelContainer #{fileUploadContainerId}" />
		</h:selectOneMenu>
		<h:message for="#{prepId}subcaracteristicaCB"
			errorClass="validationErrorMessage" showSummary="false" />
	</h:panelGrid>

	<h:panelGrid id="#{prepId}valorLabelContainer" columns="2">
		<h:outputLabel value="${msg['bienes.caracteristicasFields.valor']}"
			rendered="#{subcaracteristicaObject.tipoLista or subcaracteristicaObject.tipoDigitado}" />
		<h:outputLabel value="*"
			rendered="#{not modoConsulta and (subcaracteristicaObject.tipoLista or subcaracteristicaObject.tipoDigitado)}" />
		<ui:remove>renderRequired and </ui:remove>
	</h:panelGrid>

	<h:panelGrid id="#{prepId}camposDinamicos">
		<h:panelGrid>
			<h:inputText id="#{prepId}textValue" required="#{not modoConsulta}"
				requiredMessage="${msg['general.requerido']}"
				disabled="#{disableAllFields}"
				maxlength="250"
				size="250"
				value="#{subcaracteristicaObject.valorString}"
				rendered="#{subcaracteristicaObject.tipoTexto}" />
			<h:message for="#{prepId}textValue" showSummary="false"
				errorClass="validationErrorMessage" />
		</h:panelGrid>
		<h:panelGrid>
			<h:inputText id="#{prepId}numericValue"
				required="#{not modoConsulta}"
				maxlength="250"
				size="250"
				requiredMessage="${msg['general.requerido']}"
				onfocus="addNumericBehaviour();" disabled="#{disableAllFields}"
				styleClass="numeric" value="#{subcaracteristicaObject.valorNumber}"
				rendered="#{subcaracteristicaObject.tipoNumerico}">
			</h:inputText>
			<h:message for="#{prepId}numericValue" showSummary="false"
				errorClass="validationErrorMessage" />
		</h:panelGrid>
		
		<h:panelGrid>
			<rich:inputNumberSpinner id="#{prepId}percentageValue" maxValue="100"
				requiredMessage="${msg['general.requerido']}"
				disabled="#{disableAllFields}" minValue="0"
				value="#{subcaracteristicaObject.valorNumber}"
				required="#{not modoConsulta}"
				rendered="#{subcaracteristicaObject.tipoPorcentaje}" />
			<h:message for="#{prepId}percentageValue" showSummary="false"
				errorClass="validationErrorMessage" />
		</h:panelGrid>
		<h:panelGrid>
			<rich:calendar id="#{prepId}dateValue" datePattern="dd/MM/yyyy"
				requiredMessage="${msg['general.requerido']}"
				disabled="#{disableAllFields}" required="#{not modoConsulta}"
				defaultTime="00:00:00" dayDisableFunction="deshabilitarDiaPosterior"
				dayClassFunction="obtenerEstiloDisabled" boundaryDatesMode="hidden"
				rendered="#{subcaracteristicaObject.tipoFecha}"
				value="#{subcaracteristicaObject.valorDate}" />
			<h:message for="#{prepId}dateValue" showSummary="false"
				errorClass="validationErrorMessage" />
		</h:panelGrid>

		<h:panelGrid>
			<h:selectOneMenu id="#{prepId}listValue"
				required="#{not modoConsulta}"
				requiredMessage="${msg['general.requerido']}"
				disabled="#{disableAllFields}"
				rendered="#{subcaracteristicaObject.tipoLista}"
				value="#{subcaracteristicaObject.valorString}">
				<f:selectItems
					value="#{applicationBean.getTpSubcaracteristicaBienValoresListaSelectItems(subcaracteristicaObject)}" />
			</h:selectOneMenu>
			<h:message for="#{prepId}listValue" showSummary="false"
				errorClass="validationErrorMessage" />
		</h:panelGrid>

	</h:panelGrid>

</ui:composition>
